<template>
    <div >
        <el-button  size="mini" type="primary"  style="opacity: 0;margin:2px 3px;">隐藏的占位按钮，没有任何作用</el-button>
        <el-table  ref="receiveTable" size="mini" border :data="resData"  height="500"  @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50"></el-table-column>
            <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="aoCode" sortable label="AO编码" width="100"  :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="itemCode" sortable label="物料编码" width="100"  :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="itemName" sortable label="物料名称" width="150" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="qualityCode" sortable label="质量编号" width="150" :show-overflow-tooltip="true" > </el-table-column>
            <el-table-column prop="itemQty" sortable label="需求数量" width="150" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="matchQty" sortable label="配套数量" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="packageCount" sortable label="分拣数量" width="100"  :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="mesCheckQualiticationId" sortable label="合格证号" width="100"  :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="productCode" sortable label="机型代码" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="startPlaneNo" sortable label="架次" :show-overflow-tooltip="true"> </el-table-column>
            <el-table-column prop="isSort" sortable label="是否分拣" :show-overflow-tooltip="true"> </el-table-column>

        </el-table>
        <!-- 分页 -->
        <el-pagination  @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNumber" :page-sizes="[10,20,50,100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
        </el-pagination>
    </div>
</template>
<script>
import request from "@/utils/request.js";
export default {
    name:'WorkUnpackTopTable',
    data(){
        return {
            // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 确认列表高亮参数
            stableIndex: 0,
            value: "",
            ss: "",
            packageCode:'',
            multipleSelection:[],
        }
    },
    methods:{
        handleSelectionChange(val) {
            if(val.length>1){
                this.$refs.receiveTable.clearSelection();
                var array = val.pop();
                this.$refs.receiveTable.toggleRowSelection(array);
                this.multipleSelection = array;
                console.log(("array",array));
            }else{
                this.multipleSelection = val;
            }
            this.$bus.$emit("rigthTableData",this.multipleSelection);
        },
        handleSizeChange(val) {
            this.pageSize = val;
            request.post("/replacementAoSortiesRest/searchAo",{
                searchParams:{
                packageCode:this.packageCode,
                msTaskPackageId:this.msTaskPackageId
                },
                pageParameter:{
                    rows:this.pageSize,
                    page:this.pageNumber
                }
            }).then((res)=>{
                if(res.data.retCode == 200){
                    this.resData = res.data.retData;
                    this.totalCount = res.data.totalCount;
                }
                 
                console.log('可供替换工作包数据1',res)
            })
        },
        handleCurrentChange(val) {
            this.pageNumber = val;
            request.post("/replacementAoSortiesRest/searchAo",{
                searchParams:{
                packageCode:this.packageCode,
                msTaskPackageId:this.msTaskPackageId
                },
                pageParameter:{
                    rows:this.pageSize,
                    page:this.pageNumber
                }
            }).then((res)=>{
                if(res.data.retCode == 200){
                    this.resData = res.data.retData;
                    this.totalCount = res.data.totalCount;
                }
                console.log('可供替换工作包数据2',res)
            })
        },
        
    },
    mounted() {
        this.$bus.$on('replanPackgeSearch',(queryParam)=>{
            request.post("/replacementAoSortiesRest/searchAo",{
                searchParams:queryParam,
                pageParameter:{rows:20,page:1}
            }).then((res)=>{
                if(res.data.retCode == 200){
                    this.resData = res.data.retData;
                    this.totalCount = res.data.totalCount;
                }
                console.log('可供替换工作包数据3',res)
                this.$bus.$emit("res",res);
            })
        })
    }
}
</script>
<style scoped>


</style>